package com.ruoyi.web.districtclass.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.districtclass.mapper.DistrictclassMapper;
import com.ruoyi.web.districtclass.domain.Districtclass;
import com.ruoyi.web.districtclass.service.IDistrictclassService;

/**
 * districtclassService业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@Service
public class DistrictclassServiceImpl implements IDistrictclassService 
{
    @Autowired
    private DistrictclassMapper districtclassMapper;

    /**
     * 查询districtclass
     * 
     * @param cDCCode districtclass主键
     * @return districtclass
     */
    @Override
    public Districtclass selectDistrictclassByCDCCode(String cDCCode)
    {
        return districtclassMapper.selectDistrictclassByCDCCode(cDCCode);
    }

    @Override
    public Districtclass selectDistrictclassByCDCName(String cDCName)
    {
        return districtclassMapper.selectDistrictclassByCDCName(cDCName);
    }

    @Override
    public Map<String,String> selectDistrictclassByCDCCode1(String cDCCode)
    {
        Districtclass districtclass = districtclassMapper.selectDistrictclassByCDCCode(cDCCode);
        String country  = districtclass.getcDCCode().substring(0,1);
        String province  = districtclass.getcDCCode().substring(0,3);
        Districtclass countryclass = districtclassMapper.selectDistrictclassByCDCCode(country);
        Districtclass provinceclass = districtclassMapper.selectDistrictclassByCDCCode(province);

        Map<String,String> map = new HashMap<>();
//        map.put(districtclass.getcDCName(),"city");
//        map.put(countryclass.getcDCName(),"country");
//        map.put(provinceclass.getcDCName(),"province");
        map.put("city",districtclass.getcDCName());
        map.put("country",countryclass.getcDCName());
        map.put("province",provinceclass.getcDCName());

        return map;
    }

    /**
     * 查询districtclass列表
     * 
     * @param districtclass districtclass
     * @return districtclass
     */
    @Override
    public List<Districtclass> selectDistrictclassList(Districtclass districtclass)
    {
        for (Districtclass districtclass1 : districtclassMapper.selectDistrictclassList(districtclass)) {
            if (districtclass1.getiDCGrade() == '1'){
                
            }
        }

        return districtclassMapper.selectDistrictclassList(districtclass);
    }

    /**
     * 新增districtclass
     * 
     * @param districtclass districtclass
     * @return 结果
     */
    @Override
    public int insertDistrictclass(Districtclass districtclass)
    {
        return districtclassMapper.insertDistrictclass(districtclass);
    }

    /**
     * 修改districtclass
     * 
     * @param districtclass districtclass
     * @return 结果
     */
    @Override
    public int updateDistrictclass(Districtclass districtclass)
    {
        return districtclassMapper.updateDistrictclass(districtclass);
    }

    /**
     * 批量删除districtclass
     * 
     * @param cDCCodes 需要删除的districtclass主键
     * @return 结果
     */
    @Override
    public int deleteDistrictclassByCDCCodes(String[] cDCCodes)
    {
        return districtclassMapper.deleteDistrictclassByCDCCodes(cDCCodes);
    }

    /**
     * 删除districtclass信息
     * 
     * @param cDCCode districtclass主键
     * @return 结果
     */
    @Override
    public int deleteDistrictclassByCDCCode(String cDCCode)
    {
        return districtclassMapper.deleteDistrictclassByCDCCode(cDCCode);
    }
}
